package com.open.party.cloud.view.home.jiCengDangJian

import android.os.Bundle
import cn.android.x.model.data.ResultInfo
import cn.android.x.parent.AppEventBusRecycleViewTitleBaseActivity
import com.sinothk.android.utils.inters.OnSuperListener
import com.open.party.cloud.R
import com.open.party.cloud.model.*
import com.open.party.cloud.view.home.jiCengDangJian.org.adapter.OrgForQxXzCunListAdapter
import com.sinothk.android.utils.XUtils
import com.sinothk.rxretrofit.bean.PageVo
import kotlinx.android.synthetic.main.comm_activity_load_recycle_view_load_tip_shadow.*
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode

class OrgFor2XzListActivity : AppEventBusRecycleViewTitleBaseActivity<PartyOrgVo>(), OnSuperListener<TownshipBean> {
    private var itemData: TownshipBean?=null
    private var adapter: OrgForQxXzCunListAdapter? = null

    override fun getLayoutResId(): Int = R.layout.comm_activity_load_recycle_view_load_tip_shadow

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        itemData = intent.getSerializableExtra("itemData") as TownshipBean
        setViewTitle(XUtils.string().getNotNullValue(itemData!!.name))

        initView(itemData!!.children)
    }

    private fun initView(children: ArrayList<TownshipBean>) {
        initRecycleLinearView(loadingRecyclerView)
        loadingRecyclerView.setPullRefreshEnabled(false)
        loadingRecyclerView.setLoadingMoreEnabled(false)

        adapter = OrgForQxXzCunListAdapter(this)
        loadingRecyclerView.adapter = adapter
        adapter?.setOnSuperListener(this)

        if (children.size == 0) {
            loadingTipView.showEmpty("暂无数据", R.drawable.empty_nodata)
            loadingRecyclerView.setLoadingMoreEnabled(false)
        } else {
            adapter!!.setData(children)
            loadingTipView.showContent()
        }
    }

//    private fun refresh() {
//        loadingTipView.showLoading("努力加载中")
//        refreshData()
//    }

    override fun loadData(pageVo: PageVo<PartyOrgVo>) {
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public fun eventBusCallback(result: ResultInfo<ArrayList<TownshipBean>>) {
    }

    override fun onClick(position: Int, itemData: TownshipBean, flag: String?) {
        XUtils.intent().openActivity(this@OrgFor2XzListActivity, OrgFor3CunListActivity::class.java)
            .putSerializableExtra("itemData", itemData)
            .start()
    }
}